//
//  GFThreeTypeCell.m
//  GoodFood
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 荣伟峰. All rights reserved.
//

#import "GFThreeTypeCell.h"

@interface GFThreeTypeCell ()
@property (nonatomic, strong) UILabel *label1;
@property (nonatomic, strong) UILabel *label2;
@property (nonatomic, strong) UILabel *label3;

@property (nonatomic, strong) NSArray *array;
@end

@implementation GFThreeTypeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.array = @[@"热量", @"蛋白质", @"脂肪", @"碳水化合物", @"膳食纤维", @"维生素A", @"维生素C", @"维生素E", @"胡萝卜素", @"维生素B1", @"维生素B2", @"烟酸", @"胆固醇", @"镁", @"钙", @"铁", @"锌", @"铜", @"锰", @"钾", @"磷", @"钠", @"硒"];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.label1 = [[UILabel alloc] init];
        [self.contentView addSubview:self.label1];
      
        
        self.label2 = [[UILabel alloc] init];
        [self.contentView addSubview:self.label2];
       
        
        self.label3 = [[UILabel alloc] init];
        [self.contentView addSubview:self.label3];
        
           }
    return self;
}


- (void)setDeModel:(GFDetialsModel *)deModel {
    if (_deModel != deModel) {
        
        _deModel = deModel;
    }
    
    switch (self.rowNumber) {
        case 0: {
            self.label1.text = self.array[0];
            if (![[self.deModel.ingredient objectForKey:@"calory"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@大卡", [self.deModel.ingredient objectForKey:@"calory"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"calory"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"calory"];
            } else {
                self.label3.text = @"";
            }
            
            break;
        }
        case 1: {
            self.label1.text = self.array[1];
            if (![[self.deModel.ingredient objectForKey:@"protein"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"protein"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"protein"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"protein"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        case 2: {
            self.label1.text = self.array[2];
            if (![[self.deModel.ingredient objectForKey:@"fat"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"fat"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"fat"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"fat"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        case 3: {
            self.label1.text = self.array[3];
            if (![[self.deModel.ingredient objectForKey:@"carbohydrate"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"carbohydrate"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"carbohydrate"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"carbohydrate"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        case 4: {
            self.label1.text = self.array[4];
            if (![[self.deModel.ingredient objectForKey:@"fiber_dietary"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"fiber_dietary"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"fiber_dietary"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"fiber_dietary"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        case 5: {
            self.label1.text = self.array[5];
            if (![[self.deModel.ingredient objectForKey:@"vitamin_a"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@微克", [self.deModel.ingredient objectForKey:@"vitamin_a"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 6: {
            self.label1.text = self.array[6];
            if (![[self.deModel.ingredient objectForKey:@"vitamin_c"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"vitamin_c"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 7: {
            self.label1.text = self.array[7];
            if (![[self.deModel.ingredient objectForKey:@"vitamin_e"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"vitamin_e"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 8: {
            self.label1.text = self.array[8];
            if (![[self.deModel.ingredient objectForKey:@"carotene"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@微克", [self.deModel.ingredient objectForKey:@"carotene"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 9: {
            self.label1.text = self.array[9];
            if (![[self.deModel.ingredient objectForKey:@"thiamine"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"thiamine"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 10: {
            self.label1.text = self.array[10];
            if (![[self.deModel.ingredient objectForKey:@"lactoflavin"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"lactoflavin"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 11: {
            self.label1.text = self.array[11];
            if (![[self.deModel.ingredient objectForKey:@"niacin"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"niacin"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 12: {
            self.label1.text = self.array[12];
            if (![[self.deModel.ingredient objectForKey:@"cholesterol"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"cholesterol"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 13: {
            self.label1.text = self.array[13];
            if (![[self.deModel.ingredient objectForKey:@"magnesium"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"magnesium"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 14: {
            self.label1.text = self.array[14];
            if (![[self.deModel.ingredient objectForKey:@"calcium"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"calcium"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 15: {
            self.label1.text = self.array[15];
            if (![[self.deModel.ingredient objectForKey:@"iron"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"iron"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 16: {
            self.label1.text = self.array[16];
            if (![[self.deModel.ingredient objectForKey:@"zinc"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"zinc"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 17: {
            self.label1.text = self.array[17];
            if (![[self.deModel.ingredient objectForKey:@"copper"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"copper"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 18: {
            self.label1.text = self.array[18];
            if (![[self.deModel.ingredient objectForKey:@"manganese"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"manganese"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 19: {
            self.label1.text = self.array[19];
            if (![[self.deModel.ingredient objectForKey:@"kalium"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"kalium"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 20: {
            self.label1.text = self.array[20];
            if (![[self.deModel.ingredient objectForKey:@"phosphor"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"phosphor"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 21: {
            self.label1.text = self.array[21];
            if (![[self.deModel.ingredient objectForKey:@"natrium"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@毫克", [self.deModel.ingredient objectForKey:@"natrium"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        case 22: {
            self.label1.text = self.array[22];
            if (![[self.deModel.ingredient objectForKey:@"selenium"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@微克", [self.deModel.ingredient objectForKey:@"selenium"]];
            } else {
                self.label2.text = @"--";
            }
            
            self.label3.text = @"";
            break;
        }
        default: {
            break;
        }
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.label1.frame = CGRectMake(ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 10, ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 30);
    
    self.label2.frame = CGRectMake(ScreenWidth / 375.0 * 190, ScreenWidth / 375.0 * 10, ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 30);
    self.label2.font = [UIFont systemFontOfSize:15];
    
    self.label3.frame = CGRectMake(ScreenWidth / 375.0 * 300, ScreenWidth / 375.0 * 10, ScreenWidth / 375.0 * 75, ScreenWidth / 375.0 * 30);
    self.label3.font = [UIFont systemFontOfSize:15];
    self.label3.textColor = [UIColor lightGrayColor];
}


@end
